﻿namespace IcicleFramework.Components.Actions.ActionEffects
{
    public delegate void OnAttachHandler(IActionEffect source, IActionComponent target);

    public interface IActionEffect : ISubComponent
    {
        /// <summary>
        /// Gets whether or not this <see cref="IActionEffect"/> is permanent when attached, and can only be forcibly detached.
        /// </summary>
        bool Permanent { get; }

        /// <summary>
        /// Informs this <see cref="IActionEffect"/> that it has been attached to an <see cref="IActionComponent"/>.
        /// </summary>
        /// <param name="target">The <see cref="IActionComponent"/> this <see cref="IActionEffect"/> has been attached to.</param>
        /// <returns></returns>
        void Attached(IActionComponent target);

        /// <summary>
        /// Requests that this <see cref="IActionEffect"/> detatch itself.
        /// </summary>
        /// <param name="forceDetach">Forces this <see cref="IActionEffect"/> to detach itself no matter what.</param>
        /// <returns>True if this <see cref="IActionEffect"/> detached itself, false if otherwise.</returns>
        bool Detach(bool forceDetach = false);

        /// <summary>
        /// An event that fires when this <see cref="IActionEffect"/> detaches itself from a host <see cref="IActionComponent"/>.
        /// </summary>
        event OnAttachHandler OnDetach;

        /// <summary>
        /// An event that fires when this <see cref="IActionEffect"/> attaches itself to a host <see cref="IActionComponent"/>.
        /// </summary>
        event OnAttachHandler OnAttach;

        IActionEffect DeepClone();
    }
}
